#pragma once

#include "IXConfigNode.h"
#include "XBaseObjImpl.h"

class CXConfigNodeImpl : public CXBaseObjImpl<IXConfigNode>
{
    typedef CXBaseObjImpl<IXConfigNode> superclass;
    DEF_SKIN_CLASS_SINGLE_INTF(CXConfigNodeImpl,
        superclass,
        gs_strGuidXSkin,
        IXConfigNode,
        0);

public:
    CXConfigNodeImpl();
    virtual ~CXConfigNodeImpl();

public:
    // IXConfigNode
    virtual HRESULT STDMETHODCALLTYPE   EnumNode(IN LPCTSTR szNodePath, IN LPCTSTR szNodeName, OUT IXEnum** ppEnum);
    virtual HRESULT STDMETHODCALLTYPE   EnumAttr(OUT IXEnum** ppEnum);

    virtual void    STDMETHODCALLTYPE   GetNodeName(OUT BSTR* pbstrNodeName);

    virtual HRESULT STDMETHODCALLTYPE   GetValue(IN LPCTSTR szValueName, OUT BSTR* pbstrValue);
    virtual HRESULT STDMETHODCALLTYPE   GetValue(IN LPCTSTR szValueName, OUT LONG* plValue);
    virtual HRESULT STDMETHODCALLTYPE   GetValue(IN LPCTSTR szValueName, OUT BOOL* pbValue);

    virtual HRESULT STDMETHODCALLTYPE   GetValue(IN LPCTSTR szValueName, OUT RECT* prcValue);
    virtual HRESULT STDMETHODCALLTYPE   GetValue(IN LPCTSTR szValueName, OUT SIZE* pSizeValue);

    virtual HRESULT STDMETHODCALLTYPE   GetValue(IN LPCTSTR szValueName, OUT COLORREF* pClrValue);

    virtual HRESULT STDMETHODCALLTYPE   SetValue(IN LPCTSTR szValueName, IN LPCTSTR szValue, IN BOOL bSaveFile);

    virtual HRESULT STDMETHODCALLTYPE   DelValue(IN LPCTSTR szValueName, IN BOOL bSaveFile);

    virtual HRESULT STDMETHODCALLTYPE   SaveFile(IN LPCTSTR szFilePath);

    virtual HRESULT STDMETHODCALLTYPE   put_Node(IN XHANDLE hNode);

protected:
    TiXmlElement* GetElementByPath(LPCTSTR szPath);
    BOOL    GetValueImpl(LPCTSTR szValueName, XString& strValue);
    BOOL    SetValueImpl(LPCTSTR szValueName, LPCTSTR szValue, IN BOOL bSaveFile);

protected:
    TiXmlElement*   m_pNode;
};


